package com.jacky.iot.config;

import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.context.annotation.Configuration;

@Configuration
@ConfigurationProperties(prefix = "mqtt.client")
public class MqttClientProperties {

    private String broker;
    private String clientId;
    private String username;
    private String passwd;

    private Integer KeepAliveInterval = 30;
    private Integer ConnectionTimeout = 120;
    private Boolean cleanSession = Boolean.FALSE;

    private WillProperties will;
    private String subTopics;

    public String getBroker() {
        return broker;
    }

    public void setBroker(String broker) {
        this.broker = broker;
    }

    public String getClientId() {
        return clientId;
    }

    public void setClientId(String clientId) {
        this.clientId = clientId;
    }

    public String getUsername() {
        return username;
    }

    public void setUsername(String username) {
        this.username = username;
    }

    public String getPasswd() {
        return passwd;
    }

    public void setPasswd(String passwd) {
        this.passwd = passwd;
    }

    public Integer getKeepAliveInterval() {
        return KeepAliveInterval;
    }

    public void setKeepAliveInterval(Integer keepAliveInterval) {
        KeepAliveInterval = keepAliveInterval;
    }

    public Integer getConnectionTimeout() {
        return ConnectionTimeout;
    }

    public void setConnectionTimeout(Integer connectionTimeout) {
        ConnectionTimeout = connectionTimeout;
    }

    public Boolean getCleanSession() {
        return cleanSession;
    }

    public void setCleanSession(Boolean cleanSession) {
        this.cleanSession = cleanSession;
    }

    public WillProperties getWill() {
        return will;
    }

    public void setWill(WillProperties will) {
        this.will = will;
    }

    public String[] getSubTopics() {
        return this.subTopics.split(",");
    }

    public void setSubTopics(String subTopics) {
        this.subTopics = subTopics;
    }

    @Override
    public String toString() {
        return "MqttClientProperties{" +
                "broker='" + broker + '\'' +
                ", clientId='" + clientId + '\'' +
                ", username='" + username + '\'' +
                ", passwd='" + passwd + '\'' +
                ", KeepAliveInterval=" + KeepAliveInterval +
                ", ConnectionTimeout=" + ConnectionTimeout +
                ", cleanSession=" + cleanSession +
                ", will=" + will +
                ", subTopics='" + subTopics + '\'' +
                '}';
    }
}
